package com.example.thridhero.webchatfragment;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private List<Friends> FriendsList;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        RecyclerView view = (RecyclerView) findViewById(R.id.recycle_view);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        view.setLayoutManager(linearLayoutManager);
        linearLayoutManager.setOrientation(RecyclerView.VERTICAL);
        initFriends();
        FriendsAdapter friendsAdapter = new FriendsAdapter(FriendsList);
        view.setAdapter(friendsAdapter);

    }
    public void initFriends(){
        FriendsList = new ArrayList<Friends>();

        List<Content> contents1= new ArrayList<Content>();
        contents1.add(new Content(Content.MESSAGE_SEND,"你好"));
        contents1.add(new Content(Content.MESSSAGE_RECEVICE,"你好"));
        contents1.add(new Content(Content.MESSAGE_SEND,"你好"));
        contents1.add(new Content(Content.MESSSAGE_RECEVICE,"你好"));

        List<Content> contents2= new ArrayList<Content>();
        contents2.add(new Content(Content.MESSAGE_SEND,"你好1"));
        contents2.add(new Content(Content.MESSSAGE_RECEVICE,"你好1"));
        contents2.add(new Content(Content.MESSAGE_SEND,"你好1"));
        contents2.add(new Content(Content.MESSSAGE_RECEVICE,"你好1"));

        Friends friends = new Friends();
        friends.setImageResource(R.mipmap.a);
        friends.setContent(null);
        friends.setEndMessage("最近1忙");
        friends.setSendTime(new Date());
        friends.setUserName("张三");
        FriendsList.add(friends);
        friends.setContent(contents1);

        Friends friends2 = new Friends();
        friends2.setImageResource(R.mipmap.b);
        friends2.setContent(null);
        friends2.setEndMessage("恩恩");
        friends2.setSendTime(new Date());
        friends2.setUserName("老婆");
        FriendsList.add(friends2);
        friends2.setContent(contents2);


        Friends friends3 = new Friends();
        friends3.setImageResource(R.mipmap.b);
        friends3.setContent(null);
        friends3.setEndMessage("哈哈哈");
        friends3.setSendTime(new Date());
        friends3.setUserName("李四");
        FriendsList.add(friends3);
        friends3.setContent(contents1);


        Friends friends8 = new Friends();
        friends8.setImageResource(R.mipmap.b);
        friends8.setContent(null);
        friends8.setEndMessage("哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈");
        friends8.setSendTime(new Date());
        friends8.setUserName("李四");
        FriendsList.add(friends8);
        friends8.setContent(contents1);

        Friends friends4 = new Friends();
        friends4.setImageResource(R.mipmap.c);
        friends4.setContent(null);
        friends4.setEndMessage("哈哈哈1哈哈哈哈哈哈");
        friends4.setSendTime(new Date());
        friends4.setUserName("李四1");
        FriendsList.add(friends4);
        friends4.setContent(contents2);

        Friends friends5 = new Friends();
        friends5.setImageResource(R.mipmap.b);
        friends5.setContent(null);
        friends5.setEndMessage("哈哈哈哈哈哈哈哈哈哈哈哈");
        friends5.setSendTime(new Date());
        friends5.setUserName("李四");
        FriendsList.add(friends5);
        friends5.setContent(contents2);


        Friends friends6 = new Friends();
        friends6.setImageResource(R.mipmap.b);
        friends6.setContent(null);
        friends6.setEndMessage("哈哈哈哈哈哈哈哈哈哈哈哈");
        friends6.setSendTime(new Date());
        friends6.setUserName("李四");
        FriendsList.add(friends6);
        friends6.setContent(contents1);

        Friends friends7 = new Friends();
        friends7.setImageResource(R.mipmap.b);
        friends7.setContent(null);
        friends7.setEndMessage("哈哈哈哈哈哈哈哈哈");
        friends7.setSendTime(new Date());
        friends7.setUserName("李四");
        FriendsList.add(friends7);
        friends7.setContent(contents1);
    }
}
